﻿using System;
using System.Collections.Generic;
using System.Text;
using System.Web.Security;

namespace WebModel
{
	public class ControlBase : System.Web.UI.UserControl
	{
		PageBase basepage;

		protected override void OnInit(EventArgs e)
		{
			basepage = (PageBase)this.Parent.Page;
			base.OnInit(e);
		}

		public ControlBase()
		{
		}

		/// <summary>
		/// 当前登录身份用户
		/// </summary>
		protected MembershipUser CurrentUser
		{
			get
			{
				return basepage.CurrentUser;
			}
			set
			{
				basepage.CurrentUser = value;
			}
		}

		/// <summary>
		/// 登录
		/// </summary>
		/// <param name="UserAccount">用户名</param>
		/// <param name="Password">密码</param>
		/// <param name="isPersistent">若要创建持久 Cookie（跨浏览器会话保存的 Cookie），则为 true；否则为 false。</param>
		/// <returns>是否成功登录</returns>
		protected bool UserLogin(string UserAccount, string Password, bool isPersistent)
		{
			return basepage.UserLogin(UserAccount, Password, isPersistent);
		}

		/// <summary>
		/// 退出登录
		/// </summary>
		protected void UserLogout()
		{
			basepage.UserLogout();
		}

		/// <summary>
		/// 当前登录状态
		/// </summary>
		protected bool IsLogined
		{
			get
			{
				return basepage.IsLogined;
			}
		}

		/// <summary>
		/// 验证登录状态
		/// </summary>
		/// <param name="ReturnPageTitle">需返回页面的标题</param>
		/// <param name="ReturnUrl">返回页面地址</param>
		protected void CheckLogin(string ReturnPageTitle, string ReturnUrl)
		{
			basepage.CheckLogin(ReturnPageTitle, ReturnUrl);
		}
	}
}
